package siac.com.teste;

import java.util.List;

import org.hibernate.Session;

import siac.com.configuracao.ConexaoHibernate;
import siac.com.dao.LocPaisDao;
import siac.com.entity.LocPais;

public class AbstractFacadeTeste {
	public static void main(String[] args) {
		// AuthOperador operador = manager.getReference(AuthOperador.class, new
		// Integer(1));

		Session session = ConexaoHibernate.getSessionFactory()
		.getCurrentSession();
		try {

			LocPaisDao dao = new LocPaisDao();
			session.beginTransaction();
			LocPais bean = dao.find(18L);
			session.getTransaction().commit();


			System.out.println("REMOVENDO...............\n" + bean.toString());
			
			session.beginTransaction();
			dao.remove(bean);
			session.getTransaction().commit();
			session.close();
			
			session.beginTransaction();
			List<LocPais> lista = dao.findAll();
			session.getTransaction().commit();
			session.close();

			for (LocPais ob : lista) {
				System.out.println("OBJ\n" + ob.toString());
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

}
